<extend name="Layout/index" />

<block name="breadcrumb-01">
	<li>
		<i class="icon-home home-icon"></i>
		<a href="#">首页</a>
	</li>
	<li class="active">分类管理</li>
</block>

<block name="breadcrumb-02">
	<h1>
		分类管理
		<small>
			<i class="icon-double-angle-right"></i>
			 分类添加
		</small>
	</h1>
</block>

<block name='main'>

	<form action="<{:U('BBStype/doadd')}>" onsubmit="return click()" method="post" class='col-md-4'>
		
		<div class="form-group">
		<label for="#" class="">添加分类名称：</label>
		  <div class="input-group">
		  	 <input type="text" name="tname" class="form-control" aria-label="Amount (to the nearest dollar)">
			  
			  <span class="input-group-btn">
			  	<button id="btn" class="btn btn-success btn-sm">提交</button>
			  </span>
			 
		  </div>
		   <span style="color:red; font-size:20px;" id="info"></span>
		</div>
		 <input type="hidden" name="fid" value="<present name="Think.get.fid"><{$Think.get.fid}><else />0</present>">
	</form>
	<script src="__PUBLIC__/Admin/js/jquery-2.1.4.min.js"></script>
	<script>
		$(function(){
			$('#btn').click(function(){
				//提交表单前判断
				$('#info').html('');
				var tname = $('input[name=tname]');
				if(tname.val() == ''){
					$('#info').html('名称不能为空');
					tname.focus();
					return false;
				}
				$.ajax({
					type:'GET',
					url:"<{:U('BBStype/doAjax')}>",
					data:'tname='+$('input[name=tname]').val(),
					async:false,
					success:function(data){
						if(data == '0'){
							$('#info').html('该名称已经存在');
							result = false;
						}else{
							$('#info').html('该名称检测通过');
							result = true;
						}

					},
				})

				if(result == true){
					return true;
				}
				return false;
			})
		})
	</script>
	</block>
